home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / stdio / ftell.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  504b  |  31 lines

  1.  
  2. /*
  3.  *  FTELL.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <stdio.h>
  11.  
  12. long
  13. ftell(fi)
  14. FILE *fi;
  15. {
  16.     long n = fi->sd_Offset;
  17.  
  18.     if (!(fi->sd_Flags & __SIF_FILE))
  19.     return(EOF);
  20.  
  21.     if (fi->sd_WLeft >= 0)
  22.     return(n + (fi->sd_WPtr - fi->sd_WBuf));
  23.     else if (fi->sd_RLeft >= 0) {
  24.     if (fi->sd_UC >= 0)
  25.         --n;
  26.     return(n - fi->sd_RLeft);
  27.     }
  28.     return(n);
  29. }
  30.  
  31.